#pragma once

/**********************************************************************************
 *  用于管理加油枪，每把加油枪有lora id, 枪号、油品、LED显示屏类型、以及编码器值与油量的比值
 **********************************************************************************/

#ifndef LHJ_TERMINAL_SERVICE_OILTRANREQ_MANAGER_H__
#define LHJ_TERMINAL_SERVICE_OILTRANREQ_MANAGER_H__

#include <map>
#include <model.h>
#include <memory>
#include <cassert>
#include <vector>

namespace cores
{
    namespace devices
    {
        using namespace std;
        using namespace cores::datas::models::terminal;

        class LoraDeviceManager
        {
        public:
            LoraDeviceManager();
            virtual ~LoraDeviceManager();

            static int Count();
            static OilTransReq *Get(const uint16_t &loraId, const uint8_t &nozzlecode);
            static OilTransReq *Get(const int& i);
            static void Add(const OilTransReq &device);
            static void Add(const OilTransReq *device);
            static void Clear();
            static void Print();
            static vector<uint16_t> GetLoraIDVector();
            static const vector<OilTransReq*> GetOilTrans(const uint16_t& loraId);

        protected:
            virtual int count();
            virtual OilTransReq *get(const uint16_t &loraId, const uint8_t &nozzlecode);
            virtual OilTransReq* get(const int& i);
            virtual void add(shared_ptr<OilTransReq> device);
            virtual void clear();
            virtual void print();
            virtual vector<uint16_t> getLoraIds();
            virtual const vector<OilTransReq*> getOilTrans(const uint16_t& loraId);

        private:
            map<uint32_t, shared_ptr<OilTransReq>> _devices;
            map<uint16_t, vector<OilTransReq*>> _devicesByLoraId;
            static LoraDeviceManager *globalInstance;
        };
    }
}

#endif